<!--suppress ALL -->
<include file="./Template/header.html" />

<link rel="stylesheet" type="text/css" href="/Template/css/exam.css">
<script type="text/javascript" src="/Template/js/amazeui.js"></script>
<script type="text/javascript">


    $(function() {

        //初始化页面配置
        initPage("处方");

        if($("select[name=shankControl]").val() == "0"){
            $(".item.shankcontrolA").show();
        }
        if($("select[name=shankControl]").val() == "1"){
            $(".item.shankcontrolB").show();
        }
        if($("select[name=shankControl]").val() == "2"){
            $(".item.shankcontrolC").show();
        }
        if($("select[name=ankleType]").val() == "1"){
            $(".input_second.ankleTypeOther").show();
        }
        if($("select[name=ankleActivity]").val() == "0"){
            $(".item.ankleActivityOption1").show();
        }
        if($("select[name=ankleActivity]").val() == "1"){
            $(".item.ankleActivityOption2").show();
        }
        if($("select[name=ankleActivityOption2]").val() == "2"){
            $(".checkline_second.ankleActivityOther1").show();
        }
        if($("select[name=ankleActivityOption2]").val() == "3"){
            $(".checkline_second.ankleActivityOther2").show();
        }
        if($("select[name=ankleType]").val() == "3"){
            $(".ankle").hide();
        }

        $("select[name=shankControl]").change(function() {
            $(".item.shankcontrolA").hide();
            $(".item.shankcontrolB").hide();
            $(".item.shankcontrolC").hide();
            switch ($(this).val()) {
                case ("0"):
                    $(".item.shankcontrolA").show();
                    break;
                case ("1"):
                    $(".item.shankcontrolB").show();
                    break;
                case ("2"):
                    $(".item.shankcontrolC").show();
                    break;
                default:
                    break;
            }
        });

        $("select[name=ankleType]").change(function() {
            if($("select[name=ankleType]").val() == "3"){
                $(".ankle").hide();
            }else{
                $(".ankle").show();
            }
            $(".input_second.ankleTypeOther").hide();
            if($("select[name=ankleType]").val() == "1"){
                $(".input_second.ankleTypeOther").show();
            }
        });

        $("select[name=ankleActivity]").change(function() {
            $(".item.ankleActivityOption1").hide();
            $(".item.ankleActivityOption2").hide();
            if($("select[name=ankleActivity]").val() == "0"){
                $(".item.ankleActivityOption1").show();
            }
            if($("select[name=ankleActivity]").val() == "1"){
                $(".item.ankleActivityOption2").show();
            }
        });
        $("select[name=ankleActivityOption2]").change(function() {
            $(".checkline_second.ankleActivityOther1").hide();
            $(".checkline_second.ankleActivityOther2").hide();
            if($("select[name=ankleActivityOption2]").val() == "2"){
                $(".checkline_second.ankleActivityOther1").show();
            }
            if($("select[name=ankleActivityOption2]").val() == "3"){
                $(".checkline_second.ankleActivityOther2").show();
            }
        });

        var app = new Vue({
            el: '#container',
            data: {
            },
            methods: {
                cancel: function() {
                    window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                },
                save: function() {
                    var examAnalysisId = $("input[name=examAnalysisId]").val();
                    var workorderId = $("input[name=workorderId]").val();
                    var completed = "1";

                    var shankControl = $("select[name=shankControl]").val();
                    var shankcontrolA;
                    var shankcontrolAInside;
                    var shankcontrolB;
                    var shankcontrolC;
                    switch (shankControl) {
                        case ("0"):
                            shankcontrolA = $("select[name=shankcontrolA]").val();
                            if($("input[name=insideCheck]").is(":checked")){
                                shankcontrolAInside = "1";
                            }else{
                                shankcontrolAInside = "0";
                            }
                            break;
                        case ("1"):
                            shankcontrolB = $("select[name=shankcontrolB]").val();
                            break;
                        case ("2"):
                            shankcontrolC = $("select[name=shankcontrolC]").val();
                            break;
                        default:
                            break;
                    }
                    var ankleType = $("select[name=ankleType]").val();
                    var ankleTypeOther;
                    if(ankleType == "1"){
                        ankleTypeOther = $("input[name=ankleTypeOther]").val();
                        if(isNullOrEmpty(ankleTypeOther)){
                            completed = "-1";
                            alert("【踝关节类型：其他】未输入");
                            $("input[name=ankleTypeOther]").focus();
                            return;
                        }
                    }
                    if(ankleType != "3") {
                        var ankleSize = $("select[name=ankleSize]").val();
                        var ankleActivity = $("select[name=ankleActivity]").val();
                        var ankleActivityOption;
                        var ankleActivityOther;
                        if (ankleActivity == "0") {
                            ankleActivityOption = $("select[name=ankleActivityOption1]").val();
                            if (isNullOrEmpty(ankleActivityOption)) {
                                completed = "-1";
                                alert("【背屈辅助型】角度未选择");
                                $("select[name=ankleActivityOption1]").focus();
                                return;
                            }
                        }
                        if (ankleActivity == "1") {
                            ankleActivityOption = $("select[name=ankleActivityOption2]").val();
                            if (isNullOrEmpty(ankleActivityOption)) {
                                completed = "-1";
                                alert("【跖屈限制】未选择");
                                $("select[name=ankleActivityOption2]").focus();
                                return;
                            }
                            if (ankleActivityOption == "2") {
                                ankleActivityOther = $("input[name=ankleActivityOther1]").val();
                                if (isNullOrEmpty(ankleActivityOther)) {
                                    completed = "-1";
                                    alert("【精确调节】角度未输入");
                                    $("input[name=ankleActivityOther1]").focus();
                                    return;
                                }
                            }
                            if (ankleActivityOption == "3") {
                                ankleActivityOther = $("input[name=ankleActivityOther2]").val();
                                if (isNullOrEmpty(ankleActivityOther)) {
                                    completed = "-1";
                                    alert("【其他铰链】未输入");
                                    $("input[name=ankleActivityOther2]").focus();
                                    return;
                                }
                            }
                        }
                        if(isNullOrEmpty( ankleSize && ankleActivity )) {
                            completed = "-1";
                        }
                    }
                    if(isNullOrEmpty(shankControl
                            && (shankcontrolA || shankcontrolB || shankcontrolC)
                            && ankleType
                        )) {
                        completed = "-1";
                    }

                    $.ajax({
                        url:"/wechat/workorder/examAnalysisPost",
                        type:"post",
                        data:{
                            examAnalysisId: examAnalysisId,
                            workorderId: workorderId,
                            shankControl: shankControl,
                            shankcontrolA: shankcontrolA,
                            shankcontrolAInside: shankcontrolAInside,
                            shankcontrolB: shankcontrolB,
                            shankcontrolC: shankcontrolC,
                            ankleType: ankleType,
                            ankleTypeOther: ankleTypeOther,
                            ankleSize: ankleSize,
                            ankleActivity: ankleActivity,
                            ankleActivityOption: ankleActivityOption,
                            ankleActivityOther: ankleActivityOther,

                            completed:completed,
                        },
                        dataType:"JSON",
                        beforefootSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code == 200) {
//                                alert(data.alert);
                                alert("保存成功");
                                window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                            }
                        },
                    })

                }
            }
        })
        $(".item select").change(function() {
            var value = $(this).find("option:selected").text();
            $(this).prev().val(value);
        });
    })

</script>

<div class="container" id="container">
    <div class="hint-info">
        <span class="update_time">{$formDict.update_time}：{$examAnalysis.update_time}</span>
        <span class="employee_name">{$formDict.update_name}：{$employeeName}</span>
    </div>
    <div class="edit-info">
        <div class="edit-content">
            <input type="text" style="display: none;" name="workorderId" value="{$workorderId}">
            <input type="text" style="display: none;" name="examAnalysisId" value="{$examAnalysisId}">

            <div class="item" style="border-bottom:0px">
                <span>小腿控制能力：</span>
                <php>
                    $shankControlName = $formDict["shank_control_".$examAnalysis["shank_control"]];
                </php>
                <input id="shankControl" type="text" value="{$shankControlName}" readonly placeholder="请选择">
                <select name="shankControl">
                    <option value="{$examAnalysis.shank_control}"></option>
                    {:getFormDictSelectOptionHtml($examAnalysis['shank_control'],'shank_control','exam_analysis',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item shankcontrolA" style="display: none; border-bottom:0px;">
                <span></span>
                <php>
                    $shankcontrolAName = $formDict["shankcontrol_a_".$examAnalysis["shankcontrol_a"]];
                </php>
                <input id="shankcontrolA" type="text" value="{$shankcontrolAName}" readonly placeholder="请选择" style="width: 80%">
                <select name="shankcontrolA">
                    <option value="{$examAnalysis.shankcontrol_a}"></option>
                    {:getFormDictSelectOptionHtml($examAnalysis['shankcontrol_a'],'shankcontrol_a','exam_analysis',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item shankcontrolA" style="display: none;">
                <span></span>
                <div class="checkline_first">
                    <php>
                        $inside_checked=($examAnalysis["shankcontrol_inside"] == 1)?"checked":"";
                    </php>
                    内靴选项：<input name="insideCheck" class="checkFirst" type="checkbox" {$inside_checked}>{$formDict.shankcontrol_inside}
                </div>
            </div>
            <div class="item shankcontrolB" style="display: none;">
                <span></span>
                <php>
                    $shankcontrolBName = $formDict["shankcontrol_b_".$examAnalysis["shankcontrol_b"]];
                </php>
                <input id="shankcontrolB" type="text" value="{$shankcontrolBName}" readonly placeholder="请选择" style="width: 80%">
                <select name="shankcontrolB">
                    <option value="{$examAnalysis.shankcontrol_b}"></option>
                    {:getFormDictSelectOptionHtml($examAnalysis['shankcontrol_b'],'shankcontrol_b','exam_analysis',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item shankcontrolC" style="display: none;">
                <span></span>
                <php>
                    $shankcontrolCName = $formDict["shankcontrol_c_".$examAnalysis["shankcontrol_c"]];
                </php>
                <input id="shankcontrolC" type="text" value="{$shankcontrolCName}" readonly placeholder="请选择" style="width: 80%">
                <select name="shankcontrolC">
                    <option value="{$examAnalysis.shankcontrol_c}"></option>
                    {:getFormDictSelectOptionHtml($examAnalysis['shankcontrol_c'],'shankcontrol_c','exam_analysis',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>

            <div class="item">
                <span>踝关节类型：</span>
                <php>
                    $ankleTypeName = $formDict["ankle_type_".$examAnalysis["ankle_type"]];
                </php>
                <input id="ankleType" type="text" value="{$ankleTypeName}" readonly placeholder="请选择">
                <select name="ankleType">
                    <option value="{$examAnalysis.ankle_type}"></option>
                    {:getFormDictSelectOptionHtml($examAnalysis['ankle_type'],'ankle_type','exam_analysis',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
                <div class="input_second ankleTypeOther" style="display: none;">
                    <input name="ankleTypeOther" id="ankleTypeOther" class="otherAngle" style="width: 40%;" type="text"
                           value="{$examAnalysis.ankle_type_other}" maxlength="8" placeholder="请输入">
                </div>
            </div>

            <div class="ankle">
            <div class="item">
                <span>踝关节型号：</span>
                <php>
                    $ankleSizeName = $formDict["ankle_size_".$examAnalysis["ankle_size"]];
                </php>
                <input id="ankleSize" type="text" value="{$ankleSizeName}" readonly placeholder="请选择">
                <select name="ankleSize">
                    <option value="{$examAnalysis.ankle_size}"></option>
                    {:getFormDictSelectOptionHtml($examAnalysis['ankle_size'],'ankle_size','exam_analysis',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item">
                <span>踝活动限制：</span>
                <php>
                    $ankleActivityName = $formDict["ankle_activity_".$examAnalysis["ankle_activity"]];
                </php>
                <input id="ankleActivity" type="text" value="{$ankleActivityName}" readonly placeholder="请选择">
                <select name="ankleActivity">
                    <option value="{$examAnalysis.ankle_activity}"></option>
                    {:getFormDictSelectOptionHtml($examAnalysis['ankle_activity'],'ankle_activity','exam_analysis',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
                <div class="item ankleActivityOption1" style="border-bottom:0px; display: none;">
                    <span></span>
                    <php>
                        $ankleActivityOption1Name = $formDict["ankleactivity_option1_".$examAnalysis["ankle_activity_option"]];
                    </php>
                    <input id="ankleActivityOption1" type="text" value="{$ankleActivityOption1Name}" readonly placeholder="请选择">
                    <select name="ankleActivityOption1">
                        <option value="{$examAnalysis.ankle_activity_option}"></option>
                        {:getFormDictSelectOptionHtml($examAnalysis['ankle_activity_option'],'ankleactivity_option1','exam_analysis',0)}
                    </select>
                    <img class="icon-right" src="/Template/images/icon-right.png" alt="">
                </div>

                <div class="item ankleActivityOption2" style="border-bottom:0px; display: none;">
                    <span></span>
                    <php>
                        $ankleActivityOption2Name = $formDict["ankleactivity_option2_".$examAnalysis["ankle_activity_option"]];
                    </php>
                    <input id="ankleActivityOption2" type="text" value="{$ankleActivityOption2Name}" readonly placeholder="请选择">
                    <select name="ankleActivityOption2">
                        <option value="{$examAnalysis.ankle_activity_option}"></option>
                        {:getFormDictSelectOptionHtml($examAnalysis['ankle_activity_option'],'ankleactivity_option2','exam_analysis',0)}
                    </select>
                    <img class="icon-right" src="/Template/images/icon-right.png" alt="">
                    <div class="checkline_second ankleActivityOther1" style="border-bottom:0px; display: none;">
                        <php>
                            if($examAnalysis['ankle_activity_option'] == "2")
                                $ankleActivityOther1Value = $examAnalysis['ankle_activity_other'];
                        </php>
                        角度：<input name="ankleActivityOther1" id="ankleActivityOther1" class="otherAngle" type="text"
                                  value="{$ankleActivityOther1Value}" placeholder="请输入">
                    </div>
                    <div class="checkline_second ankleActivityOther2" style="border-bottom:0px; display: none;">
                        <php>
                            if($examAnalysis['ankle_activity_option'] == "3")
                                $ankleActivityOther2Value = $examAnalysis['ankle_activity_other'];
                        </php>
                        限制说明：<input name="ankleActivityOther2" id="ankleActivityOther2" class="otherAngle" type="text"
                                    value="{$ankleActivityOther2Value}" placeholder="请输入" maxlength="20" style="width: 70%">
                    </div>
                </div>
            </div>
            </div>



            <div class="line"></div>
        </div>
    </div>
    <div class="operation-btn">
        <div class="cancle-btn" v-on:click="cancel">取消</div>
        <if condition="$workorder['status'] eq '-1' && $workorder['examinator_id'] eq $customerId">
            <div class="save-btn" v-on:click="save">保存</div>
        </if>
    </div>

</div>
<include file="./Template/footer.html" />